//
//  FilterViewController.m
//  KiklinkApp
//
//  Created by LJC on 14-9-23.
//  Copyright (c) 2014年 Kiklink. All rights reserved.
//

#import "FilterViewController.h"

#import "UIColor+hex.h"
#import "ImagesManager.h"

#import "ClassifyButton.h"

@interface FilterViewController ()

@property (strong, nonatomic) IBOutlet UIView *distanceTag;
@property (strong, nonatomic) IBOutlet UILabel *distanceLabel;
@property (strong, nonatomic) IBOutlet UILabel *distanceRange;

@property (strong, nonatomic) IBOutlet UIView *classifyTag;
@property (strong, nonatomic) IBOutlet UILabel *classifyLabel;

@end

@implementation FilterViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = @"筛选";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    //BundleImages
    ImagesManager *imagesManager = [ImagesManager sharedImagesManager];
    
    
    //leftNavItem
    UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
    [cancelButton setTitleColor:[UIColor colorWithHexString:AppColor_Text] forState:UIControlStateNormal];
    cancelButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [cancelButton setFrame:CGRectMake(0, 0, NavBarHeight, NavBarHeight/2)];
    [cancelButton addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftNavBarItem = [[UIBarButtonItem alloc] initWithCustomView:cancelButton];
    self.navigationItem.leftBarButtonItem = leftNavBarItem;
    
    
    //rightNavItem
    UIButton *confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [confirmButton setTitle:@"确定" forState:UIControlStateNormal];
    [confirmButton setTitleColor:[UIColor colorWithHexString:AppColor_Text] forState:UIControlStateNormal];
    confirmButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [confirmButton setFrame:CGRectMake(0, 0, NavBarHeight, NavBarHeight/2)];
    [confirmButton addTarget:self action:@selector(confirm) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightNavBarItem = [[UIBarButtonItem alloc] initWithCustomView:confirmButton];
    self.navigationItem.rightBarButtonItem = rightNavBarItem;
    
    
    //slider
    self.distanceTag.backgroundColor = [UIColor colorWithHexString:AppColor_slider];
    self.distanceLabel.textColor = [UIColor colorWithHexString:AppColor_Text];
    self.distanceRange.textColor = [UIColor colorWithHexString:AppColor_slider];
    
    self.slider.minimumTrackTintColor = [UIColor colorWithHexString:AppColor_slider];
    self.slider.maximumTrackTintColor = [UIColor colorWithHexString:AppColor_sliderUnselected];
    [self.slider setThumbImage:[imagesManager slider] forState:UIControlStateNormal];
    [self.slider setThumbImage:[imagesManager sliderTapped] forState:UIControlStateHighlighted];
    [self.slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];

    
    //classify
    self.classifyTag.backgroundColor = [UIColor colorWithHexString:AppColor_Main];
    self.classifyLabel.textColor = [UIColor colorWithHexString:AppColor_Text];
    
//    NSArray *classifyArray = @[@"健身",@"瑜伽",@"普拉提",@"马术",@"卡丁车",@"羽毛球",@"乒乓球",@"篮球",@"足球",@"排球",@"拳击",];
//    for (int i = 0; i < classifyArray.count; i ++) {
//        ClassifyButton *classBtn = [ClassifyButton buttonWithPosition:CGPointMake(ScreenWidth*15/320+(i%3)*100, StatusBarHeight+NavBarHeight+ScreenWidth*172/320+15+29+(i/3)*50) andTitle:[classifyArray objectAtIndex:i]];
//        [classBtn addTarget:self action:@selector(classifyButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
//        [self.view addSubview:classBtn];
//    }
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navItemAction
- (void)cancel
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)confirm
{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - navItemAction End

#pragma mark - slider
- (void)sliderValueChanged:(id)sender
{
    
}
#pragma mark - slider End

#pragma mark - classifyButtonTapped
- (IBAction)classifyButtonTapped:(id)sender
{
    [(ClassifyButton *)sender changeStyle];
}
#pragma mark - classifyButtonTapped End

@end
